// 入口js文件
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App.jsx'
import 'antd/dist/antd.less'
// 引入antd中文文案
import { ConfigProvider } from 'antd'
import zhCN from 'antd/lib/locale/zh_CN'
// 调用 render() 方法，实现浏览器中 DOM 渲染操作
import './components/layout.less'
// 引入路由
import { writeRoutes } from './routes'
import { BrowserRouter as Router, Route, Switch, Redirect } from "react-router-dom"
// 
import { Provider } from 'react-redux' // 缓存store
import store from './redux/store'
ReactDOM.render(
  <Provider store={store}>
    <Router>
      <ConfigProvider locale={zhCN}>
        <Switch>
          <Redirect from="/" to="/admin" exact />
          {
            writeRoutes.map(route => (
              <Route path={route.path} component={route.component} key={route.meta.id}></Route>
            ))
          }
          <Route path="/admin" component={App} />
          <Redirect to="/404" />
        </Switch>
      </ConfigProvider>
    </Router>
  </Provider>,
  document.getElementById('root')
)